package com.tanhua.server.controller;

import com.tanhua.model.vo.AnswerVo;
import com.tanhua.model.vo.QuestionnairesVo;
import com.tanhua.model.vo.ReportConclusionVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testSoul")
public class TestSoulController {
    @Autowired
    private TestSoulService testSoulService;

    @RequestMapping(method = RequestMethod.GET)
    public ResponseEntity testSoul() {
        List<QuestionnairesVo> questionnairesVoList = testSoulService.testSoul();
        return ResponseEntity.ok(questionnairesVoList);
    }

    @PostMapping
    public ResponseEntity submitResport(@RequestBody Map<String,List<AnswerVo>> paramMap){
        String id=testSoulService.submitReport(paramMap);
        return ResponseEntity.ok(id);
    }

    /**
     * 查看报告
     * @param reportId
     * @return
     */
    @GetMapping("/report/{id}")
    public ResponseEntity viewResults(@PathVariable("id") String reportId) {
        ReportConclusionVo reportConclusionVo = testSoulService.viewResults(reportId);
        return ResponseEntity.ok(reportConclusionVo);
    }

}